# Verification script for Dinghong Cloud Screen deployment
# This script checks if all components are properly configured

$ErrorActionPreference = "Stop"

Write-Host "Verifying Dinghong Cloud Screen deployment configuration..." -ForegroundColor Green

# Get script directory
$SCRIPT_DIR = Split-Path -Parent $MyInvocation.MyCommand.Path

# Check if all required files exist
$requiredFiles = @(
    "namespace.yaml",
    "mysql-deployment.yaml", 
    "redis-deployment.yaml",
    "server-deployment.yaml",
    "web-deployment.yaml",
    "nginx-config.yaml",
    "nginx-ingress.yaml",
    "configmap-server.yaml"
)

Write-Host "Checking required files..." -ForegroundColor Yellow
foreach ($file in $requiredFiles) {
    $filePath = Join-Path $SCRIPT_DIR $file
    if (Test-Path $filePath) {
        Write-Host "✓ $file" -ForegroundColor Green
    }
    else {
        Write-Host "✗ $file (missing)" -ForegroundColor Red
    }
}

# Check if scripts exist
$requiredScripts = @(
    "build-images.ps1",
    "deploy.ps1", 
    "cleanup.ps1"
)

Write-Host "`nChecking required scripts..." -ForegroundColor Yellow
foreach ($script in $requiredScripts) {
    $scriptPath = Join-Path $SCRIPT_DIR $script
    if (Test-Path $scriptPath) {
        Write-Host "✓ $script" -ForegroundColor Green
    }
    else {
        Write-Host "✗ $script (missing)" -ForegroundColor Red
    }
}

# Check Docker
Write-Host "`nChecking Docker..." -ForegroundColor Yellow
try {
    $dockerVersion = docker version 2>$null
    if ($LASTEXITCODE -eq 0) {
        Write-Host "✓ Docker is available" -ForegroundColor Green
    }
    else {
        Write-Host "✗ Docker is not available" -ForegroundColor Red
    }
}
catch {
    Write-Host "✗ Docker is not available" -ForegroundColor Red
}

# Check Minikube
Write-Host "`nChecking Minikube..." -ForegroundColor Yellow
try {
    $minikubeVersion = minikube version 2>$null
    if ($LASTEXITCODE -eq 0) {
        Write-Host "✓ Minikube is available" -ForegroundColor Green
    }
    else {
        Write-Host "✗ Minikube is not available" -ForegroundColor Red
    }
}
catch {
    Write-Host "✗ Minikube is not available" -ForegroundColor Red
}

# Check kubectl
Write-Host "`nChecking kubectl..." -ForegroundColor Yellow
try {
    $kubectlVersion = kubectl version --client 2>$null
    if ($LASTEXITCODE -eq 0) {
        Write-Host "✓ kubectl is available" -ForegroundColor Green
    }
    else {
        Write-Host "✗ kubectl is not available" -ForegroundColor Red
    }
}
catch {
    Write-Host "✗ kubectl is not available" -ForegroundColor Red
}

Write-Host "`nVerification completed!" -ForegroundColor Green
Write-Host "If all checks pass, you can proceed with deployment." -ForegroundColor Cyan 